/**
 * Tab选项卡效果
 * const tab=new Tab('el',{})
 * @param {sting} el 
 * @param {*} options 
 */

function Tab(el, options = {}) {
    this.el = document.querySelector(el);
    this.init();
}

Tab.prototype.init=function(){
    this.titleOver()
}

Tab.prototype.titleOver=function () {
    let ulLiObjs=this.el.querySelectorAll('ul li')
    ulLiObjs.forEach((item,i) => {
        item.onmouseover = () => {
            this.el.querySelector('ul li.active').className=''
            item.className='active'
            this.changeContent(i)
        };
    });
};
Tab.prototype.changeContent=function(i) {
    this.el.querySelector('ol li.active').className='';
    this.el.querySelector(`ol li:nth-of-type(${i + 1})`).className='active';
}

export default Tab;